﻿using TMS.Model;

namespace TMS.Dal
{
    public class Memdal
    {
        public Memdal(MyContent myContent)
        {
            MyContent = myContent;
        }

        public MyContent MyContent { get; }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public Admin Login(string name,string pwd)
        {
            try
            {
                Admin admin = MyContent.Admin.Where(x => x.AName == name && x.APwd == pwd).FirstOrDefault();
                return admin;
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        
        /// <summary>
        /// 显示加查询
        /// </summary>
        /// <param name="name"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        public List<Member> GetMembers(string?  name, string? age)
        {
            try
            {
                List<Member> members = MyContent.Member.ToList();
                if (!string.IsNullOrEmpty(name))
                {
                     MyContent.Member.Where(x =>x.Name.Contains(name));
                }
                if (!string.IsNullOrEmpty(age))
                {
                    MyContent.Member.Where(x =>x.Age == age);
                }
                return members;
            }
            catch (Exception)
            {

                throw;
            }
          
        }
    }
}
